import 'package:abc/view/PaymentMethodSheet.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class RedeemController extends GetxController {
  final codeController = TextEditingController();
  
  @override
  void onClose() {
    codeController.dispose();
    super.onClose();
  }

  // 兑换功能
  void redeemCode(BuildContext context) {
    final code = codeController.text.trim();
    if (code.isEmpty) {
      Get.snackbar('提示', '请输入兑换码');
      return;
    }
    showModalBottomSheet(
      context: context,
      isScrollControlled: true,
      backgroundColor: Colors.transparent,
      builder: (context) {
        return Padding(
          padding: const EdgeInsets.symmetric(horizontal: 15.0),
          child: PaymentMethodSheet(
            onConfirm: (selectedMethod) {
              // 在这里处理选中的支付方式
              String paymentMethodName = selectedMethod == PaymentMethod.wechat ? '微信' : '支付宝';
              Get.snackbar('支付方式', '您选择了：$paymentMethodName');
              // TODO: 在这里添加实际的支付逻辑
            },
          ),
        );
      },
    );
  }
}